package com.mallcloud.mall.app.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.mallcloud.mall.common.core.util.R;
import com.mallcloud.mall.mall.api.entity.MallMyParkingCouponModel;
import com.mallcloud.mall.mall.api.entity.MallPointsDiscountRuleModel;
import com.mallcloud.mall.mall.service.MallMyParkingCouponService;
import com.mallcloud.mall.mall.service.MallPointsDiscountRuleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 美美停车场使用
 */
@Api(tags = "app-积分停车抵扣券")
@RestController
@AllArgsConstructor
@RequestMapping("/app/mmPointsCouponParking")
public class AppMMPointsCouponParkingController {
	private final MallMyParkingCouponService mallMyParkingCouponService;
	private final MallPointsDiscountRuleService mallPointsDiscountRuleService;

	@ApiOperation("查询积分抵扣规则")
	@GetMapping("/rule")
	public R<MallPointsDiscountRuleModel> getParkingPointRuleByKey(MallPointsDiscountRuleModel dto) {
		return R.ok(mallPointsDiscountRuleService.getOne(new LambdaQueryWrapper<>(dto)));
	}

	@ApiOperation("停车抵扣券-列表")
	@GetMapping("/myParkingCouponList")
	public R<List<MallMyParkingCouponModel>> myParkingCouponList(MallMyParkingCouponModel dto) {
		return R.ok(mallMyParkingCouponService.list(Wrappers.lambdaQuery(dto).orderByDesc(MallMyParkingCouponModel::getGetTime)));
	}
}